from os import path

from loguru import logger

from core.config import settings

LOG_FORMATE = "{time:YYYY-MM-DD HH:mm:ss.SSS} | {level:<8} | {name}:{function}:{line} - {message}"


def set_log() -> None:
    logger.remove()

    logger.add(
        sink=path.join(settings.LOG_DIR, "error_{time}.log"),
        format=LOG_FORMATE,
        rotation=settings.LOG_ROTATION,
        level="ERROR",
        enqueue=True,
    )

    logger.add(
        sink=path.join(settings.LOG_DIR, "debug_{time}.log"),
        format=LOG_FORMATE,
        rotation=settings.LOG_ROTATION,
        level="DEBUG",
        enqueue=True,
    )
